package com.bm.server.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bm.server.dto.HavegiDto;
import com.bm.server.entity.Havegi;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface HavegiDao extends BaseMapper<Havegi> {
    //礼物查询接口
    @Select("select * from t_havegi h,t_gift g where uid = #{uid} having h.tid=g.id")
    List<HavegiDto> selectGift(Integer uid);
    //查询某个用户，某个礼物是否拥有
    @Select("select * from t_havegi where uid = #{uid} and tid = #{tid}")
    HavegiDto selectHavegi(int uid,int tid);
    //增加用户礼物
    @Insert("insert into t_havegi (uid,num,tid) value(#{uid},#{num},#{tid})")
    int insertHavgi(int uid, int num, int tid);
    //更新用户礼物
    @Update("update t_havegi set num = #{num} where id = #{id}")
    int updateHavgi(int num,int id);

    //删除用户礼物
    @Delete("delete from t_havegi where id = #{id}")
    int delHavgi(int id);

}
